package com.itmuch.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.web.client.RestTemplate;

import com.itmuch.config.TestConfiguration;

/*
 * 使用注解配置ribbon负载均衡：
 * 		1.在maven添加配置
 * 		2.在主类添加注解@RibbonClient	
 * 		3.以上是正常的使用
 * 		4.创建TestConfiguration.java，这个是自定义的ribbon,记住自定义的ribbon的包不要在主类的同包和子包
 * 		
 * 
 * */

@ComponentScan(excludeFilters= {@ComponentScan.Filter(type=FilterType.ANNOTATION,value=Exclude.class)})
@RibbonClient(name="microservice-provider-user",configuration=TestConfiguration.class)
@EnableEurekaClient
@SpringBootApplication
public class MicroserviceSimpleRibbonApplication {
	
	@Bean
	@LoadBalanced
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
	public static void main(String[] args) {
		SpringApplication.run(MicroserviceSimpleRibbonApplication.class, args);
	}
}
